package com.haidechizi.designpattern.proxy.dynamic.cglib;

import net.sf.cglib.proxy.Enhancer;

/**
 * @author haidechizi
 */
public class ProxyHelper {

    public static <T> T createProxy(Class<T> clazz) {
        // 代理类class文件存入本地磁盘方便我们反编译查看源码
//        System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "D:\\code");
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(clazz);
        enhancer.setCallback(new DynamicLog());
        return (T) enhancer.create();
    }
}
